import datetime
from models import db
from models.tasks import Task
class Record(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80),nullable=False)
    description = db.Column(db.String(200))
    time = db.Column(db.DateTime)
    status = db.Column(db.String(40))
    task_id = db.Column(db.Integer,db.ForeignKey('task.id'))

    def __init__(self, dic):
        for key,value in dic.items():
            setattr(self, key, value)
    
    def __repr__(self):
        return '{}:{}:{}'.format(self.name,self.time,self.status)

tags = db.Table(
        'recordtags',
        db.Column('record_id',db.Integer, db.ForeignKey('record.id')),
        db.Column('tag_id',db.Integer, db.ForeignKey('tag.id'))
)
